DonationOfferPopup = function() {
	donationOfferPopupThis = this;
	
	donationOfferPopupThis._HTMLDom = null;
}
DonationOfferPopup.prototype = {
	donationOfferView : function() {
		var mj = new MJson();
		var cm = new ConnectionManager();
		
		mj.putClient(MJson.CLIENT.USERID, document.globalObj.LOGIN_DATA.userId);
		mj.putPub(MJson.PUB.SID, "DR001");
		mj.putPub(MJson.PUB.SERVICENAME, "DonationDetailView");

		mj.putParameter("reserveSeq", document.globalObj.DONATION_DATA.donation_seq);

		console.log("request : " + mj.getJsonString());
		cm.requestGet(mj.getJsonString(), function(jsonData) {
			console.log("성공 :: 통신");

			if (mj.checkServiceResult(jsonData)) {
				console.log("success :: " + JSON.stringify(jsonData));
				bookingDonationViewThis.bookingDonationViewJson=jsonData
				//console.log('donationMainReserveList :: 성공');

				//------- UI Display -------//
				var $contents = donationOfferPopupThis._HTMLDom.contents;
				var $offerPrice = donationOfferPopupThis._HTMLDom.offerPrice;
				var $offerPriceHtml='결제금액  :   '+addPeriod(jsonData.msp.contents.items.donatePrice)+'원  ';
				$offerPrice.html($offerPriceHtml);
				$contents.append($offerPrice);
				
				//--------------------------// 
				//UI객체 
			} else {
				console.log('donationMainReserveList :: 실패');
			}
		}, function(e) {
			console.log("실패 :: 통신");
		});
	},
	onPageShow : function() {
		console.log("DonationOfferPopup :: onPageShow");
		$('a').attr('href', '');
		$('a').attr('data-rel', '');
		var $sumbitBtn = $("#donation_offer_btn_contents").find('a:eq(0)');
		var $cancelBtn = $("#donation_offer_btn_contents").find('a:eq(1)');
		
		var $contents = $("#donation_offer_contents"); 
		var $offerPrice=$contents.find('p:eq(2)');
		this._HTMLDom = {
			"contents" : $contents,
			"offerPrice" : $offerPrice
		}
		$offerPrice.empty();
		this.donationOfferView();
		
		$sumbitBtn.bind('click', function(event) {
			$.mobile.changePage('donation_account.html');
		});

		$cancelBtn.bind('click', function(event) {
			$.mobile.changePage('donation_view.html');
		});

	}
}
function addPeriod(nStr) {
	nStr += '';
	x = nStr.split(',');
	x1 = x[0];
	x2 = x.length > 1 ? ',' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}
